<!-- 活动类型管理 -->
<template>
  <page-header-wrapper>
    <a-card class="table-card">
      <GzSearchForm :searchFunc="searchFunc" :resetFunc="()=>{ searchData = {} }">
        <!-- <GzTextUp placeholder="活动类型ID" v-model:value="searchData['activityTypeId']"/> -->
        <GzTextUp v-model:value="searchData['goodsName']" placeholder="商品名称" />
        <a-form-item class="table-search-item">
          <a-select v-model:value="searchData['type']" :placeholder="'商品类型'">
            <a-select-option :value="0">卡密商品</a-select-option>
            <a-select-option :value="1">代充商品</a-select-option>
          </a-select>
        </a-form-item>
      </GzSearchForm>
      <!-- 列表渲染 -->
      <GzTable
        ref="infoTableRef"
        :init-data="true"
        :req-table-data-func="reqTableDataFunc"
        :table-columns="tableColumns"
        :search-data="searchData"
        row-key="activityTypeId"
        :scrollX="0"
      >
        <template #bodyCell="{ column, record }">
          <template v-if="column.key == 'goodsImgBanner'">
            <a-image :src="record.goodsImgBanner" /> 
          </template>
          <template v-if="column.key == 'goodsImgListSmall'">
            <a-image :src="record.goodsImgListSmall" />  
          </template>
          <template v-if="column.key == 'goodsImgListBig'">
            <a-image :src="record.goodsImgListBig" />
          </template>
          <template v-if="column.key == 'goodsPrice'">
            <!-- marketPrice 分转换成元 -->
            <template v-if="record.goodsPrice">{{ record.goodsPrice/100 }}</template>
          </template>
          <template v-if="column.key == 'marketPrice'">
            <!-- marketPrice 分转换成元 -->
            <template v-if="record.marketPrice">{{ record.marketPrice/100 }}</template>
          </template>
          <template v-if="column.key == 'type'">
            <template v-if="record.type == 0">卡密商品</template>
            <template v-if="record.type == 1">代充商品</template>
          </template>
        </template>
      </GzTable>
    </a-card>
  </page-header-wrapper>
</template>
  
  <script lang="ts" setup>
  // import { req, API_URL_VIRTUAGOODS_INSIDE, $transferGoods,$getAgentList,API_URL_VIRTUALGOODS_INSIDE_SAVE } from '@/api/manage'
  import {$apiVirtualGoodsInside,$apiVirtualGoodsInsideSaveCdkNum,$transferGoods,$getAgentList,$getUploadFormParams,$apiVirtualAwardCdkImportCdk,$getUsedCdkList} from '@/api/externalGoods/innertable/index'
  import { ref, reactive, getCurrentInstance } from 'vue'
  const { $infoBox, $access } = getCurrentInstance()!.appContext.config.globalProperties
  const infoTableRef = ref()
  const tableColumns = reactive([
    { key: 'goodsName', title: '商品名称',dataIndex: 'goodsName' },
    { key: 'goodsImgListSmall', title: '商品图片--列表小图',dataIndex: 'goodsImgListSmall' },
    { key: 'goodsImgListBig', title: '商品图片--列表大图',dataIndex: 'goodsImgListBig' },
    { key: 'goodsPrice', title: '商品进价（元）',dataIndex: 'goodsPrice' },
    { key: 'marketPrice', title: '市场价（元）',dataIndex: 'marketPrice' },
    { key: 'type', title: '商品类型',dataIndex: 'type' },
    { key: 'remark', title: '备注', dataIndex:'remark' },
    { key: 'operation', title: '操作', dataIndex: 'operation', align: 'center' ,width: 180 }
  ])
  const searchData:any = ref({})
  // 请求table接口数据
  function reqTableDataFunc(params: any) {
      return  $apiVirtualGoodsInside(params)
  }
  function searchFunc() {
    infoTableRef.value.refTable(true)
  }
  </script>
  <style lang="less" scoped>
  :deep(img){
    width: 80px;
    height: 80px;
    object-fit: cover;
  }
  </style>